import React, { useState, useEffect, useCallback, FC } from 'react'
import { Link, useLocation } from 'react-router-dom'
import { Menu, Layout } from 'antd'
import menus,{getMenu} from '@/config/menu' 
import MyIconFont from '@/components/common/myIconfont'
import { getKeyName, flattenRoutes } from '@/assets/js/publicFunc'
import logo from '@/assets/img/logo.png'
import { connect } from 'react-redux'
import * as actions from '@/store/actions'
import styles from './Menu.module.less'
const { SubMenu } = Menu
interface Props extends ReduxProps {}

type MenuType = CommonObjectType<string>
const Webview: FC<Props> = ({ storeData: { } }) => {
  const { pathname } = useLocation()
  const { tabKey: curKey = 'home' } = getKeyName(pathname)
  const [current, setCurrent] = useState(curKey)
  const [currentexternalLink,setCurrentObjexternalLink] = useState(null)
  
  useEffect(()=>{
    let flatMenu = flattenRoutes(menus)
    console.log(flatMenu);
    flatMenu.map((e,i)=>{
      if(e.key==current){
        setCurrentObjexternalLink(e.externalLink)
      }
    })
  },[])
  return (
    <div className="home" style={{ padding: 20 }}>
      <iframe style={{width:'100%',height:'100%',overflowY:'auto',margin:0,border:'0'}} src={currentexternalLink}></iframe>
      
    </div>
  )
}


export default connect(
  (state) => state,
  actions
)(Webview)



